package sebjul.ecom.listeners;

import java.util.List;

import javax.ejb.*;
import javax.servlet.*;
import javax.servlet.annotation.*;

import sebjul.ecom.dao.*;
import sebjul.ecom.entities.*;

public class ContextInitialization implements ServletContextListener {
	private static final long serialVersionUID = 1L;
	
	@EJB
	GenreDao genreDao;
	
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		List<Genre> genres = genreDao.findGenres();
		ServletContext servletContext = event.getServletContext();
		servletContext.setAttribute("genres", genres);
	}
}
